package workspace;

import java.io.IOException;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import stores.FoglalasStore;
import stores.FoglalasStoreImpl;
import beans.Foglalas;
import beans.Foglalo;
import beans.Terem;
import beans.Tipus;

public class Main {

	public static void main(String[] args) throws SQLException, ParseException {
		Workspace workspace = null;
		try {
			try {
				workspace = Workspace.getWorkspace("Tomi", "TestPassword");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if (workspace.getAktualisOperator() == null) {
				System.out.println("Login failed.");
			} else {
				System.out.println("Login success.");
			}
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
			FoglalasStore foglalasStore = new FoglalasStoreImpl();
			Foglalas newFoglalas = new Foglalas();
			newFoglalas.setElrendezes("V alak");
			newFoglalas.setMegjegyzes("Kiraj?");
			Foglalo newFoglalo = new Foglalo();
			newFoglalo.setId(1);
			newFoglalas.setFoglalo(newFoglalo);
			Terem newTerem = new Terem();
			newTerem.setId(3);
			newFoglalas.setTerem(newTerem);
			Tipus newTipus = new Tipus();
			newTipus.setId(13);
			newFoglalas.setTipus(newTipus);
			Calendar fromDate = Calendar.getInstance();
			fromDate.setTime(sdf.parse("2014.04.22 10:30:00"));
			Calendar toDate = Calendar.getInstance();
			toDate.setTime(sdf.parse("2014.04.22 12:30:00"));
			newFoglalas.setFromDate(fromDate);
			newFoglalas.setToDate(toDate);
			foglalasStore.insertFoglalas(workspace, newFoglalas);

			// TipusStore tipusStore = new TipusStoreImpl();
			// tipusStore.loadTipusById(workspace, 13);
			// Tipus tipus = new Tipus();
			// tipus.setTipusNev("Proba3");
			// tipus = tipusStore.insertTipus(workspace, tipus);
			// System.out.println(tipus);
			// OperatorManager operatorManager = new OperatorManagerImpl();
			// Operator newOperator = new Operator();
			// newOperator.setFelhasznaloNev("Tomi");
			// newOperator.setJelszoHash("TestPassword");
			// newOperator.setEmail("baloght@lvs.co.uk");
			// newOperator.setTelefonSzam("06304541888");
			// System.out.println(operatorManager.insertOperator(workspace,
			// newOperator));
			// OperatorManager operatorManager = new OperatorManagerImpl();
			// Operator newOperator = new Operator();
			// newOperator.setId(1);
			// newOperator.setEmail("testoperator@lvs.co.uk");
			// System.out.println(operatorManager.updateOperator(workspace,
			// newOperator));

		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

	}
}
